<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function userName() {
            return new Promise((resolve, reject) => {
                try {
                    // throw new Error('A数据请求失败')
                    console.log('开始请求A数据');
                    setTimeout(() => {
                        const Data = {
                            name: '晓月'
                        }
                        resolve(Data)
                        console.log('A数据请求成功');
                    }, 2000);
                } catch (e) {
                    reject(e.message)
                }
            })
        }
        function userAge(name) {
            return new Promise((resolve, reject) => {
                try {
                    // throw new Error('B数据请求失败')
                    console.log('开始请求B数据');
                    setTimeout(() => {
                        const Data = {
                            age: 18
                        }
                        resolve({ ...name, ...Data })
                        console.log('B数据请求成功');
                    }, 2000);
                } catch (e) {
                    reject(e.message)
                }
            })
        }
        function userSex(sex) {
            return new Promise((resolve, reject) => {
                try {
                    // throw new Error('C数据请求失败')
                    console.log('开始请求C数据');
                    setTimeout(() => {
                        const Data = {
                            sex: '男'
                        }
                        resolve({ ...sex, ...Data })
                        console.log('C数据请求成功');
                    }, 2000)
                }
                catch (e) {
                    reject(e.message)
                }
            })
        }

        async function getData() {
            const name = await userName();
            const age = await userAge(name);
            const sex = await userSex(age);
            console.log(sex);
        }
        getData()
    </script>
</body>

</html>